-- CartoonM
-- created by zouyb
-- 漫画配置模块

module("CartoonM", package.seeall);

local cartoonConfig = {};
local cartoonTextConfig = {};
local cartoonBubbleConfig = {};
local cartoonEffectConfig = {};

-- 载入配置表
local _init = false;
local loadCsv = function()
    if _init then return end
    _init = true;

    cartoonConfig = {};
    cartoonTextConfig = {};

    -- 载入漫画配置表
    local cartoonCSV = get_cartoon_CSV();
    for _, info in pairs(cartoonCSV) do
        cartoonConfig[info.id] = info;
    end

    -- 载入文字框配置表
    local cartoonTextCSV = get_cartoon_text_CSV();
    for _, info in pairs(cartoonTextCSV) do
        cartoonTextConfig[info.id] = info;
    end
    
    -- 载入底框配置表
    local cartoonIconCSV = get_cartoon_bubble_CSV();
    for _, info in pairs(cartoonIconCSV) do
        cartoonBubbleConfig[info.id] = info;
    end
    
    -- 载入特效配置表
    local cartoonEffectCSV = get_cartoon_effect_CSV();
    for _, info in pairs(cartoonEffectCSV) do
        cartoonEffectConfig[info.id] = info;
    end    
end

-- 模块初始化操作
function init()
    loadCsv();
end

-- 检索配置
function query(classId, path)
    local m = cartoonConfig[classId];
    if nil == m then
        return nil;
    end
    if (path == "" or path == nil) then
        return m;
    else
        return m[path];
    end
end

-- 检索文字框配置信息
function queryTextInfo(textId, path)
    local m = cartoonTextConfig[textId];
    if nil == m then
        return nil;
    end
    if (path == "" or path == nil) then
        return m;
    else
        return m[path];
    end    
end

-- 检索底框信息
function queryBubbleInfo(bubbleId, path)
    local m = cartoonBubbleConfig[bubbleId];
    if nil == m then
        return nil;
    end
    if (path == "" or path == nil) then
        return m;
    else
        return m[path];
    end    
end

-- 检索特效信息
function queryEffectInfo(bubbleId, path)
    local m = cartoonEffectConfig[bubbleId];
    if nil == m then
        return nil;
    end
    if (path == "" or path == nil) then
        return m;
    else
        return m[path];
    end    
end
